package com.huawei.orderservice.mapper;


import com.huawei.orderservice.pojo.dto.OrderUpdateDTO;
import com.huawei.orderservice.pojo.entity.Order;
import com.huawei.orderservice.pojo.entity.OrderDetail;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper {

    @Insert("insert into douyue.orders (id,user_id,create_time,address,consignee,remark,phone)" +
            "values (#{id},#{userId},#{createTime},#{address},#{consignee},#{remark},#{phone})")
    void addOrder(Order orders);

    void addOrderDetail(List<OrderDetail> orderDetail);



    void updateOrder(OrderUpdateDTO order);

    @Update("update douyue.orders set status = 0 where id = #{id}")
    void cancelOrder(Long id);

    @Select("select * from douyue.orders_detail where order_id = #{id}")
    List<OrderDetail> getOrderDetail(Long id);
}
